#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

class Solution
{
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs)
    {
        unordered_map<string, vector<string>> hash;
        for (auto& ch : strs)
        {
            string tmp = ch;
            sort(tmp.begin(), tmp.end());
            hash[tmp].push_back(ch);
        }

        vector<vector<string>> ret;
        for (auto& [x,y] : hash)
        {
            ret.push_back(y);
        }
        return ret;
    }
};